﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>课程订单管理管理</title>
    <#include "../common/link.ftl">
    <script src="/js/plugins/messager/jquery.bootstrap.min.js"></script>
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <#include "../common/navbar.ftl">
    <!--菜单回显-->
    <#assign currentMenu="courseorder_list"/>
    <#include "../common/menu.ftl">
    <div class="content-wrapper">
        <section class="content-header">
            <h1>潜在客户管理</h1>
        </section>
        <section class="content">
            <div class="box">
                <!--高级查询--->
                <form class="form-inline" id="searchForm" action="/courseorder/list.do" method="post">
                    <div class="form-group">
                        <label for="keyword">关键字:</label>
                        <input type="text" class="form-control" id="keyword" name="keyword" value="${qo.keyword!}"
                               placeholder="请输入姓名/电话">
                    </div>
                    <@shiro.hasAnyRoles name="admin,Market_Manager">
                    <div class="form-group">
                        班级课程:
                        <select class="form-control" name="classinfoId" id="empl">
                            <option value="-1">全部</option>
                            <#list classinfo as employee>
                                <option value="${employee.id}"  ${((qo.classinfoId!-1) == employee.id) ?string("selected","")}>${employee.name}</option>
                            </#list>
                        </select>
                    </div>
                    </@shiro.hasAnyRoles>
                    <button id="btn_query" class="btn btn-primary"><span class="glyphicon glyphicon-search"></span>
                        查询
                    </button>
                    <input type="hidden" name="currentPage" id="currentPage" value="1">
                    <a href="#" class="btn btn-success btn-input" style="margin: 10px">
                        <span class="glyphicon glyphicon-plus"></span> 添加
                    </a>
                </form>
                <!--编写内容-->
                <div class="box-body table-responsive no-padding ">
                    <table class="table table-hover table-bordered">
                        <tr>
                            <th>编号</th>
                            <th>客户名称</th>
                            <th>班级课程</th>
                            <th>销售时间</th>
                            <th>销售金额</th>
                            <th>操作</th>
                        </tr>
                        <#list pageInfo.list as courseorder>
                            <tr>
                                <td>${courseorder_index+1}</td>
                                <td>${(courseorder.customer.name)!}</td>
                                <td>${(courseorder.classinfo.name)!}</td>
                                <td>${(courseorder.inputTime?string("yyyy-MM-dd"))!}</td>
                                <td>${(courseorder.money)!}</td>
                                <td>
                                    <a href="#" class="btn btn-info btn-xs btn-input" data-id='${courseorder.json!}'>
                                        <span class="glyphicon glyphicon-pencil"></span> 编辑
                                    </a>
                                </td>
                            </tr>
                        </#list>
                    </table>
                    <!--分页-->
                    <#include "../common/page.ftl">
                </div>
            </div>
        </section>
    </div>
    <#include "../common/footer.ftl">
</div>

<!-- Button trigger modal -->
<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
    Launch demo modal
</button>

<!-- Modal -->
<div class="modal fade" id="editModal">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title inputTitle">客户编辑</h4>
            </div>
            <form class="form-horizontal" action="/courseorder/saveOrUpdate.do" method="post" id="editForm">
                <div class="modal-body">
                    <input type="hidden" name="id">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">选择客户：</label>
                        <div class="col-sm-6">
                            <select class="form-control" name="customer.id">
                                <option value="">请选择</option>
                                <#list customers as j>
                                    <option value="${(j.id)!}">${j.name!}</option>
                                </#list>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">班级课程：</label>
                        <div class="col-sm-6">
                            <select class="form-control" name="classinfo.id">
                                <option value="">请选择</option>
                                <#list classinfo as s>
                                    <option value="${s.id!}">${s.name!}</option>
                                </#list>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">销售金额：</label>
                    <div class="col-sm-6">
                        <input type="number" class="form-control" name="money"
                               placeholder="请输金额">
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary btn-submit">保存</button>
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                </div>
            </form>
        </div>
    </div>
</div>
<script>
    $('.btn-input').click(function () {
        $('#editModal').modal('show');
        $('#editForm input,#editForm select').val('');
        var data = $(this).data('id');
        console.log(data);
        if (data) {
            $('#editForm input[name="id"]').val(data.id);
            $('#editForm select[name="classinfo.id"]').val(data.classinfoId);
            $('#editForm select[name="customer.id"]').val(data.customerId);
            $('#editForm input[name="money"]').val(data.money);
        }
    });

    $(function () {
        $('.btn-submit').click(function () {
            $('#editForm').ajaxSubmit(handlerMessage);
        })
    })
</script>

</body>
</html>
